package mrusanov.tournament

import mrusanov.team.{Team, Club}
import mrusanov.money.PrizeMoneyChangeReason

class KnockOutRoundTournamentReward(loserReward:Int, winnerReward:Int) extends TournamentReward{
  def payReward(results:List[Team]) {
    require(results.size % 2 == 0, "Clubs count must be even!")

    val winners = results.take(results.size / 2)
    val losers = results.takeRight(results.size / 2)

    winners foreach(c => c.club.clubBudget.acceptMoneyChangeReason(PrizeMoneyChangeReason(winnerReward)))
    losers foreach(c => c.club.clubBudget.acceptMoneyChangeReason(PrizeMoneyChangeReason(loserReward)))
  }
}
